/*
** det_info.c for rt in /home/le_e//project/project_b2/raytracer
** 
** Made by canh-kiet le
** Login   <le_e@epitech.net>
** 
** Started on  Sat Apr 28 17:34:43 2012 canh-kiet le
** Last update Mon Apr 30 18:59:59 2012 canh-kiet le
*/

#include	"rt.h"

static int	det_size(t_scene *sc, int i)
{
  static int	obj_len = 0;
  static int	lgt_len = 0;

  if (i == LGT)
    {
      sc->lgt = realloc(sc->lgt, (lgt_len + 2) * sizeof(*sc->lgt));
      sc->lgt[lgt_len++].end = 0;
      sc->lgt[lgt_len].end = 1;
    }
  if (i >= 2)
    {
      sc->obj = realloc(sc->obj, (obj_len + 2) * sizeof(*sc->obj));
      sc->obj[obj_len].type = i - 2;
      sc->obj[obj_len++].end = 0;
      sc->obj[obj_len].end = 1;
      return (OBJ);
    }
  return (i);
}

int		det_type(char *line, t_check *check, t_scene *sc)
{
  int		i;

  i = 0;
  while (check[TYP].name_info[i])
    {
      if (my_strcmp(line, check[TYP].name_info[i]) == 0)
	{
	  i = det_size(sc, i);
	  return (i);
	}
      i++;
    }
  return (-1);
}
